//:C05:CountedClass2.cpp
// Erroneous attempt to count objects.
#include <iostream>
using namespace std;

class Counted
{
    static int count;
    public:
        Counted(){++count;}
        Counted(const Counted&){++count;}
        ~Counted(){--count;}
        static int getCount(){return count;}
};

int Counted::count = 0;
class CountedClass : public Counted{};
class CountedClass2 : public Counted{};

int main(void)
{
    CountedClass a;
    cout << CountedClass::getCount() << endl;    // 1
    CountedClass b;
    cout << CountedClass::getCount() << endl;    // 2
    CountedClass2 c;
    cout << CountedClass2::getCount() << endl;   // 3 (Error)
}
